<?php
namespace app\work\validate;
use think\Validate;

/**
 * 工作记录内部协同信息验证器
 * Created by PhpStorm.
 * User: tyll
 * Date: 2019/10/29
 * Time: 15:38
 */
class WorkRecordXt extends Validate{

    protected $rule = [
        'name'        => 'require',
        'content'     => 'require',
        'out_time'    => 'require|date|checkOutTime',
        'deal_openid' => 'require',
        'pic'         => 'require',
    ];

    protected $message = [
        'name.require'          => '名称必须填写',
        'content.require'       => '内容必须填写',
        'out_time.require'      => '截止时间必须填写',
        'out_time.date'         => '截止时间填写错误',
        'out_time.checkOutTime' => '截止时间必须大于当前时间',
        'deal_openid.require'   => '移交对象必须填写',
        'pic.require'           => '图片必须填写',
    ];

    protected function checkOutTime($value){
        $now_time = date('Y-m-d H:i:s');
        return $now_time >= $value ? false : true;
    }

    protected $scene = [
        'add'  => ['name','content','deal_openid'],
        'edit' => ['name','content','deal_openid']
    ];
}